Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
I2C Master peripheral

The section describes the programming interface of the I2C master mode Peripheral driver. More...

Data Structures

struct  i2c_device_t
 Information necessary to communicate with an I2C slave device. More...
 
struct  i2c_master_t
 Internal driver state information. More...
 

Enumerations

enum  i2c_direction_t {
  kI2CRead = 1,
  kI2CWrite = 0
}
 Constants for the direction of an I2C transfer. More...
 
enum  _i2c_transfer_flags {
  kI2CNoStart = 1 << 1,
  kI2CNoStop = 1 << 2
}
 Optional flags to control a transfer. More...
 

I2C Master

void i2c_master_init (uint32_t instance, i2c_master_t *master)
 Initialize the I2C master mode driver. More...
 
void i2c_master_shutdown (i2c_master_t *master)
 Shut down the driver. More...
 
i2c_status_t i2c_master_configure_bus (i2c_master_t *master, const i2c_device_t *device)
 Configure the I2C bus to access a device. More...
 
i2c_status_t i2c_master_transfer_basic (i2c_master_t *master, uint32_t flags, i2c_direction_t direction, uint8_t *data, size_t dataLength, size_t *actualLengthTransferred, uint32_t timeout_ms)
 Low-level I2C transfer function. More...
 
i2c_status_t i2c_master_transfer (i2c_master_t *master, const i2c_device_t *device, i2c_direction_t direction, bool stopAfterTransfer, uint32_t subaddress, size_t subaddressLength, uint8_t *data, size_t dataLength, size_t *actualLengthTransferred, uint32_t timeout_ms)
 Perform a blocking read or write transaction on the I2C bus. More...
 

Data Structure Documentation

struct i2c_device_t

Data Fields

uint8_t address
 The slave's 7-bit address. More...
 
uint32_t baudRate_kbps
 The baud rate in kbps to use with this slave device. More...
 

Field Documentation

uint8_t i2c_device_t::address
uint32_t i2c_device_t::baudRate_kbps
struct i2c_master_t
Note
The contents of this structure are internal to the driver and should not be modified by users. Also, contents of the structure are subject to change in future releases.

Data Fields

uint32_t instance
 
bool isTransferInProgress
 
uint32_t flags
 
i2c_direction_t direction
 
uint8_t * data
 
volatile size_t dataRemainingCount
 
volatile size_t bytesTransferredCount
 
volatile bool gotNak
 
uint32_t lastBaudRate_kbps
 
sync_object_t irqSync
 

Enumeration Type Documentation

Enumerator
kI2CRead 

Read from slave device.

kI2CWrite 

Write to slave device.

Enumerator
kI2CNoStart 

Set this flag to prevent sending a START signal.

kI2CNoStop 

Set this flag to prevent sending a STOP signal.

Function Documentation

void i2c_master_init ( uint32_t  instance,
i2c_master_t master 
)
Parameters
instanceThe I2C peripheral instance number.
masterThe pointer to the I2C master driver state structure.
void i2c_master_shutdown ( i2c_master_t master)
Parameters
masterThe pointer to the I2C master driver state structure.
i2c_status_t i2c_master_configure_bus ( i2c_master_t master,
const i2c_device_t device 
)
Parameters
masterThe pointer to the I2C master driver state structure.
deviceThe pointer to the I2C device information struct.
i2c_status_t i2c_master_transfer_basic ( i2c_master_t master,
uint32_t  flags,
i2c_direction_t  direction,
uint8_t *  data,
size_t  dataLength,
size_t *  actualLengthTransferred,
uint32_t  timeout_ms 
)
Parameters
masterThe pointer to the I2C master driver state structure.
flagsThe flags to control a transfer.
directionThe direction of an I2C transfer.
dataThe pointer to the data to be transfered.
dataLengthThe length in bytes of the data to be transfered.
actualLengthTransferredThe length in bytes of the data thansfered.
timeous_msA timeout for the transfer in microseconds.
i2c_status_t i2c_master_transfer ( i2c_master_t master,
const i2c_device_t device,
i2c_direction_t  direction,
bool  stopAfterTransfer,
uint32_t  subaddress,
size_t  subaddressLength,
uint8_t *  data,
size_t  dataLength,
size_t *  actualLengthTransferred,
uint32_t  timeout_ms 
)
Parameters
masterThe pointer to the I2C master driver state structure.
deviceThe pointer to the I2C device information struct.
directionThe direction of an I2C transfer.
stopAfterTransferSend STOP signal after this transfer or not.
subaddressThe subaddress for a device if it has.
subaddressLengthThe length of the subaddress.
dataThe pointer to the data to be transfered.
dataLengthThe length in bytes of the data to be transfered.
actualLengthTransferredThe length in bytes of the data thansfered.
timeous_msA timeout for the transfer in microseconds.